<?php
namespace app\admin\form;

use app\common\loglic\Form;

class Cache extends Form
{
    public function items($data=[])
    {
        $placeholderExpire = '留空禁用缓存、0为永久缓存';
        return [
            'type' => [
                'type'        => 'select',
                'value'       => $data['type'],
                'option'      => [
                    'File'      => 'File',
                    'Memcache'  => 'Memcache',
                    'Memcached' => 'Memcached',
                    'Redis'     => 'Redis',
                    'Wincache'  => 'Wincache',
                    'Xcache'    => 'Xcache',
                ],
                'required'    => true,
                'title'       => '缓存方式',
                'class_row'   => 'col-4 mb-3',
            ],
            'path' => [
                'type'        => 'text',
                'value'       => xfEmpty($data['path'],'./runtime/cache/'),
                'title'       => '缓存路径',
                'required'    => true,
                'class_row'   => 'col-4 mb-3',
            ],
            'prefix' => [
                'type'        => 'text',
                'value'       => $data['prefix'],
                'required'    => true,
                'title'       => '缓存前缀',
                'class_row'   => 'col-4 mb-3',
            ],
            'host' => [
                'type'        => 'text',
                'value'       => $data['host'],
                'required'    => false,
                'title'       => '缓存服务器IP',
                'class_row'   => 'col-4 mb-3',
            ],
            'port' => [
                'type'        => 'text',
                'value'       => $data['port'],
                'required'    => false,
                'title'       => '缓存服务器端口',
                'class_row'   => 'col-4 mb-3',
            ],
            'expire' => [
                'type'        => 'number',
                'value'       => $data['expire'],
                'required'    => false,
                'title'       => '全局缓存有效期',
                'placeholder' => $placeholderExpire,
                'class_row'   => 'col-4 mb-3',
            ],
            'expire_detail' => [
                'type'        => 'number',
                'value'       => $data['expire_detail'],
                'required'    => false,
                'title'       => '普通数据缓存有效期',
                'placeholder' => $placeholderExpire,
                'class_row'   => 'col-4 mb-3',
            ],
            'expire_items' => [
                'type'        => 'number',
                'value'       => $data['expire_items'],
                'required'    => false,
                'title'       => '数据列表缓存有效期',
                'placeholder' => $placeholderExpire,
                'class_row'   => 'col-4 mb-3',
            ],
        ];
    }
}